package c.e.a.b.f.b;

import b.f.a;
import b.f.g;
import b.f.g.c;
import b.f.h;
import c.e.a.b.e.c.g1;
import c.e.a.b.e.c.h1;
import c.e.a.b.e.c.h9;
import c.e.a.b.e.c.u4;
import c.e.a.b.e.c.y0;
import c.e.a.b.e.c.z0;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */
public final class da {
    public String a;
    public boolean b;
    public g1 c;
    public BitSet d;
    public BitSet e;
    public Map<Integer, Long> f;
    public Map<Integer, List<Long>> g;
    public final /* synthetic */ ba h;

    public da(ba baVar, String str, aa aaVar) {
        this.h = baVar;
        this.a = str;
        this.b = true;
        this.d = new BitSet();
        this.e = new BitSet();
        this.f = new a();
        this.g = new a();
    }

    public final y0 a(int i) {
        Iterable iterable;
        y0.a F = y0.F();
        if (F.c) {
            F.j();
            F.c = false;
        }
        y0.u((y0) F.b, i);
        boolean z = this.b;
        if (F.c) {
            F.j();
            F.c = false;
        }
        y0.w((y0) F.b, z);
        g1 g1Var = this.c;
        if (g1Var != null) {
            if (F.c) {
                F.j();
                F.c = false;
            }
            y0.z((y0) F.b, g1Var);
        }
        g1.a M = g1.M();
        List B = q9.B(this.d);
        if (M.c) {
            M.j();
            M.c = false;
        }
        g1.D((g1) M.b, B);
        B = q9.B(this.e);
        if (M.c) {
            M.j();
            M.c = false;
        }
        g1.y((g1) M.b, B);
        if (this.f == null) {
            iterable = null;
        } else {
            iterable = new ArrayList(this.f.size());
            for (Integer intValue : this.f.keySet()) {
                int intValue2 = intValue.intValue();
                z0.a A = z0.A();
                if (A.c) {
                    A.j();
                    A.c = false;
                }
                z0.u((z0) A.b, intValue2);
                long longValue = ((Long) this.f.get(Integer.valueOf(intValue2))).longValue();
                if (A.c) {
                    A.j();
                    A.c = false;
                }
                z0.v((z0) A.b, longValue);
                iterable.add((z0) ((u4) A.l()));
            }
        }
        if (M.c) {
            M.j();
            M.c = false;
        }
        g1.F((g1) M.b, iterable);
        if (this.g == null) {
            iterable = Collections.emptyList();
        } else {
            iterable = new ArrayList(this.g.size());
            for (Integer intValue3 : this.g.keySet()) {
                h1.a B2 = h1.B();
                int intValue4 = intValue3.intValue();
                if (B2.c) {
                    B2.j();
                    B2.c = false;
                }
                h1.v((h1) B2.b, intValue4);
                List list = (List) this.g.get(intValue3);
                if (list != null) {
                    Collections.sort(list);
                    if (B2.c) {
                        B2.j();
                        B2.c = false;
                    }
                    h1.w((h1) B2.b, list);
                }
                iterable.add((h1) ((u4) B2.l()));
            }
        }
        if (M.c) {
            M.j();
            M.c = false;
        }
        g1.H((g1) M.b, iterable);
        if (F.c) {
            F.j();
            F.c = false;
        }
        y0.v((y0) F.b, (g1) ((u4) M.l()));
        return (y0) ((u4) F.l());
    }

    public final void b(ea eaVar) {
        long longValue;
        int a = eaVar.a();
        Boolean bool = eaVar.c;
        if (bool != null) {
            this.e.set(a, bool.booleanValue());
        }
        bool = eaVar.d;
        if (bool != null) {
            this.d.set(a, bool.booleanValue());
        }
        if (eaVar.e != null) {
            Long l = (Long) this.f.get(Integer.valueOf(a));
            longValue = eaVar.e.longValue() / 1000;
            if (l == null || longValue > l.longValue()) {
                this.f.put(Integer.valueOf(a), Long.valueOf(longValue));
            }
        }
        if (eaVar.f != null) {
            List list = (List) this.g.get(Integer.valueOf(a));
            if (list == null) {
                list = new ArrayList();
                this.g.put(Integer.valueOf(a), list);
            }
            if (eaVar.g()) {
                list.clear();
            }
            if (h9.a() && this.h.a.g.u(this.a, p.c0) && eaVar.h()) {
                list.clear();
            }
            if (h9.a() && this.h.a.g.u(this.a, p.c0)) {
                longValue = eaVar.f.longValue() / 1000;
                if (!list.contains(Long.valueOf(longValue))) {
                    list.add(Long.valueOf(longValue));
                }
                return;
            }
            list.add(Long.valueOf(eaVar.f.longValue() / 1000));
        }
    }

    public da(ba baVar, String str, g1 g1Var, BitSet bitSet, BitSet bitSet2, Map map, Map map2, aa aaVar) {
        this.h = baVar;
        this.a = str;
        this.d = bitSet;
        this.e = bitSet2;
        this.f = map;
        this.g = new a();
        Iterator it = ((c) ((a) map2).keySet()).iterator();
        while (true) {
            g.a aVar = (g.a) it;
            if (aVar.hasNext()) {
                Integer num = (Integer) aVar.next();
                ArrayList arrayList = new ArrayList();
                arrayList.add((Long) ((h) map2).get(num));
                this.g.put(num, arrayList);
            } else {
                this.b = false;
                this.c = g1Var;
                return;
            }
        }
    }
}
